Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms
Imports System
Imports System.Threading


Public Class FrmCrNXTTongHop_NhieuThang
    Dim maKho, tenKho As String
    Dim fromDate, toDate As String
    Dim customerReport As ReportDocument

    Delegate Sub WaitDelegate()

    Private Sub FrmCrNXTTongHop_NhieuThang_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        globalVariale.runWaitting = True
        Dim wd As New WaitDelegate(AddressOf moduleWaitting.runningWait)
        wd.BeginInvoke(Nothing, Nothing)

        tinhton.tinhXuatNhapTonTongHop_NhieuThang(fromDate, toDate, maKho)

        Dim sqlQuery As String = ""

        sqlQuery = "SELECT * FROM tbl_dot_nhapxuattonghop_nhieuthang ORDER BY ten_bietduoc"

        customerReport = New ReportDocument()
        Dim reportPath = Application.StartupPath & "\" & "crNhapXuatTonTongHop_NhieuThang.rpt"
        customerReport.Load(reportPath)
        customerReport.SetDataSource(moduleReportConfig.GetDataTable(sqlQuery))
        customerReport.SetParameterValue("tenKho", tenKho)
        customerReport.SetParameterValue("fromDate", fromDate)
        customerReport.SetParameterValue("toDate", toDate)
        customerReport.SetParameterValue("company", globalVariale.COMPANY)
        customerReport.SetParameterValue("address", globalVariale.ADDRESS)
        Me.CrNXTTongHopview.ReportSource = customerReport

        globalVariale.runWaitting = False
    End Sub

    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub
    Public Sub setFromDate(ByVal fd As String)
        fromDate = fd
    End Sub

    Public Sub settoDate(ByVal td As String)
        toDate = td
    End Sub

    Public Sub setTenKho(ByVal s As String)
        tenKho = s
    End Sub

    Public Sub setMaKho(ByVal s As String)
        maKho = s
    End Sub
End Class
